package com.weizhu.swufer.core.cluster;

import com.weizhu.swufer.core.entity.InvokeParam;
import com.weizhu.swufer.core.exception.RpcBizException;
import com.weizhu.swufer.core.loadbalance.LoadBalancer;
import com.weizhu.swufer.core.exception.RpcException;
import com.weizhu.swufer.core.rpc.RpcRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FastFailClusterInvoker extends AbstractClusterInvoker{

    private static final Logger logger = LoggerFactory.getLogger(FastFailClusterInvoker.class);


    @Override
    public Object doInvoke(InvokeParam invokeParam, String address) {
        RpcRequest rpcRequest = invokeParam.getRpcRequest();
        try {
            return invokeGrpc(invokeParam,address);
        }catch (RpcException | RpcBizException e){
            throw e;
        } catch(Exception e){
            throw new RpcException(e.getMessage(),e.getCause());
        }
    }
}
